import { AddPrinterComponent } from './addPrinter';
import { ConfigDeviceComponent } from './configDevice';
import { WifiPrintComponent } from './wifiPrint';
import { SearchDeviceComponent } from './searchDevice';
import { DeviceInterfaceComponent } from './deviceInterface';
import { DeviceTypeComponent } from './deviceType';
import { PrinterComponent } from './printer.component';
import { routeModel } from './../setup/index';
import { PrinterContainerComponent } from './templates/printcontainer.component';

export class PrintService {
    static current = new PrintService();
    route: routeModel = {
        path: 'printer', component: PrinterComponent, title: "打印", url: "printer",
    }
    components = [PrinterContainerComponent, AddPrinterComponent, DeviceTypeComponent, DeviceInterfaceComponent, SearchDeviceComponent, WifiPrintComponent, ConfigDeviceComponent]
    pipes = []
    forRoot() {
        function traverse(data) {
            let arr = [];
            arr.push(data.component);
            for (let key in data) {
                if (Array.isArray(data[key])) {
                    data[key].forEach(v => {
                        arr = arr.concat(traverse(v))
                    })
                }
            }
            return arr;
        }
        // let components = traverse({component:PrinterContainerComponent});
        let components = traverse(this.route);
        return components.concat(this.components);
        // return components.concat(this.components).concat(this.pipes);
    }
}